package cn.easy.controller;

import cn.easy.confirm.MyConfirmCallback;
import cn.easy.confirm.MyReturnCallback;
import org.mybatis.spring.boot.autoconfigure.MybatisAutoConfiguration;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author 张澎_9970
 * @date 2021.12.15 下午 3:04 星期三
 * @desc:
 *  RabbitMQ,高级功能
 *
 */
@RestController
@RequestMapping("advanced")
public class AdvancedController {
    @Autowired
    private RabbitTemplate rabbitTemplate;
    @Autowired
    private MyConfirmCallback confirmCallback;
    @Autowired
    private MyReturnCallback returnCallback;

    @GetMapping("send/{msg}")
    public String send1(@PathVariable String msg) {
        rabbitTemplate.setConfirmCallback(confirmCallback);
        rabbitTemplate.setReturnCallback(returnCallback);

        rabbitTemplate.convertAndSend("Ex_01", "item.insert","mq message: " + msg);
        return "OK";
    }

}
